#!/usr/bin/python3
# connect.py: connect to the MySQL Server
import pymysql

try:
    conn = pymysql.connect(database='cookbook',
                                 host='localhost',
                                 user='cbuser',
                                 password='cb')
    print("Connected")
except pymysql.MySQLError as e:
    print("Cannot connect to server")
    print("Error code: %s" % str(e.args))
else:
    conn.close()
    print("Disconnected")
